import { SupabaseClient } from '@supabase/supabase-js'

import { MessageRoleEnum, MessageStatusEnum } from '@/configs/enums'

class ThreadController {
  private supabase: SupabaseClient

  constructor(supabase: SupabaseClient) {
    this.supabase = supabase
  }

  async createThread(title: string) {
    const { data, error } = await this.supabase
      .from('threads')
      .insert({
        title,
      })
      .select('id')
      .single()

    if (error) {
      throw new Error(error.message)
    }
    return data.id
  }
}

export default ThreadController
